# coding:utf-8

__author__ = 'devwork@163.com'

from  django.contrib.auth.admin import admin
from django.db import models
from DjangoUeditor.models import UEditorField

class tag(models.Model):
    name = models.CharField(u'标签',max_length=30)
    def __unicode__(self):
        return self.name


class blog(models.Model):
    author = models.CharField(u'作者',max_length=12)
    title = models.CharField(u'标题',max_length=100)
    title_en = models.CharField(u'英文标题',max_length=100)
    summary = models.CharField(u'概述',max_length=300)
    thumbnail_image = models.ImageField(upload_to='images/')

    create_time = models.DateTimeField(u'创建时间')
    mod_time = models.DateTimeField(u'修改时间',auto_now=True,auto_created=True)
    content = UEditorField(u'内容',width=800, height=500, toolbars="full", imagePath="images/", filePath="files/", upload_settings={"imageMaxSize":1204000},
             settings={},command=None,blank=True)
    n_views = models.IntegerField(u'浏览次数',default=0)
    n_comments = models.IntegerField(u'回复条数',default=0)


    tags = models.ManyToManyField(tag)


    def __unicode__(self):
        return self.title

class commentator(models.Model):
    name = models.CharField(u'评论人',max_length=30)
    email = models.EmailField()
    def __unicode__(self):
        return self.name

class comment(models.Model):
    n_number = models.IntegerField(u'第几条')
    reply_to = models.OneToOneField(blog)
    commentator = models.OneToOneField(commentator)
admin.site.register(blog)
admin.site.register(tag)